package priv.yiyuan.example.design.product;

import priv.yiyuan.example.design.product.strategy.PriceCalculationStrategy;

/**
 * @author YiYuan
 * @data 2025/8/14
 * @apoNote
 */
public class Product {

    private String name;

    private double originalPrice;

    private PriceCalculationStrategy priceStrategy;

    public Product(String name, double originalPrice, PriceCalculationStrategy priceStrategy) {
        this.name = name;
        this.originalPrice = originalPrice;
        this.priceStrategy = priceStrategy;
    }

    public void setPriceStrategy(PriceCalculationStrategy priceStrategy) {
        this.priceStrategy = priceStrategy;
    }

    public String getName() {
        return name;
    }

    public double getCalculatedPrice() {
        return priceStrategy.calculatePrice(originalPrice);
    }
}
